package org.huoran.sakamichi.study.S_20170605_annotation.service;

import org.huoran.sakamichi.study.S_20170605_annotation.TestAnn;
import org.huoran.sakamichi.main.util.ResultBean;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;

@Service
public class AnnService {
    @TestAnn(name = "testName")
    private int testNum;

    public ResultBean testAnn(){
        try {
            Field field = AnnService.class.getDeclaredField("testNum");
            TestAnn ann = field.getAnnotation(TestAnn.class);
            String name = ann.name();
            return ResultBean.success("Ann test success",name);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
            return ResultBean.failed("Ann test failed");
        }
    }
}
